﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

class PromotionDAL : BaseDAL
{
    internal System.Data.DataSet List(int pageIndex, int pageMax, int isActive)
    {
        DataSet ds = new DataSet();
        //string[] uspParaName = new string[] { "?pageIndex", "?pageMax", "?_IsActive" };
        //object[] uspParaValue = new object[] { pageIndex, pageMax, isActive };
        //string uspName = "usp_promotion_list";

        //ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        string query = string.Format("select * from [dbo].[Promotion] ");
        ds = base.RunQuery(query);

        return ds;
    }

    internal System.Data.DataSet Detail(int Id)
    {
        DataSet ds = new DataSet();
        string[] uspParaName = new string[] { "?_Id" };
        object[] uspParaValue = new object[] { Id };
        string uspName = "usp_promotion_detail";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }

    internal System.Data.DataSet UpdateStatusActive(int id, int isActive)
    {
        DataSet ds = new DataSet();
        string[] uspParaName = new string[] { "?_id", "?_IsActive" };
        object[] uspParaValue = new object[] { id, isActive};
        string uspName = "usp_promotion_updateActive";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }

    internal System.Data.DataSet Update(int id, string name, string title, string description, string content, string image, DateTime fromDate, DateTime toDate, int status, int isActive, string contentDetail)
    {
        DataSet ds = new DataSet();
        string[] uspParaName = new string[] { "?_Id", "?_Name", "?_Title", "?_Description", "?_Content", "?_Image", "?_FromDate", "?_ToDate", "?_Status", "?_IsActive", "?_ContentDetail" };
        object[] uspParaValue = new object[] { id, name, title, description, content, image, fromDate, toDate, status, isActive, contentDetail };
        string uspName = "usp_promotion_update";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }

    internal System.Data.DataSet Insert(string name, string title, string description, string content, string image, DateTime fromDate, DateTime toDate, int status, int isActive, string contentDetail)
    {
        DataSet ds = new DataSet();
        string[] uspParaName = new string[] { "?_Name", "?_Title", "?_Description", "?_Content", "?_Image", "?_FromDate", "?_ToDate", "?_Status", "?_IsActive", "?_ContentDetail", "?_CreatedDate" };
        object[] uspParaValue = new object[] { name, title, description, content, image, fromDate, toDate, status, isActive, contentDetail, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") };
        string uspName = "usp_promotion_insert";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }
}
